package com.example.springbooteasyexcel.web;

import com.alibaba.excel.EasyExcel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class IndexController {


    @Autowired
    private DemoDAO demoDAO;

    @RequestMapping("upload")
    public String upload(@RequestParam("file") MultipartFile file) throws IOException {

        // 将 bean 注入使用
        EasyExcel.read(file.getInputStream(), Exception.class, new UploadDataListener(demoDAO)).sheet().doRead();

        return "success";
    }


}
